package com.bw.finance.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bw.finance.conf.ResponseResult;
import com.bw.finance.eneity.locana.EbankLoanInfo;
import com.bw.finance.eneity.locana.EbankMgInfo;
import com.bw.finance.mapper.EbankMgInfoMapper;
import com.bw.finance.service.IEbankMgInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zxx
 * @since 2020-08-19
 */
@Service
public class EbankMgInfoServiceImpl extends ServiceImpl<EbankMgInfoMapper, EbankMgInfo> implements IEbankMgInfoService {

    private final Logger logger = LoggerFactory.getLogger(ServiceImpl.class);

    @Resource
    private IEbankMgInfoService iEbankMgInfoService;

    @Override
    public ResponseResult findonegrtId(int id) {
        logger.info("开始查询借款信息的担保对象");
        ResponseResult result = ResponseResult.SUCCESS();
        try{
            QueryWrapper<EbankMgInfo> queryWrapper = new QueryWrapper<>();
            queryWrapper.lambda().eq(EbankMgInfo::getLidId,id);
            List<EbankMgInfo> list = iEbankMgInfoService.list(queryWrapper);
            EbankMgInfo ebankMgInfo = list.get(0);
            result.setResult(ebankMgInfo);
            logger.info("查询借款信息的担保对象结束");
        }catch (Exception e){
            result.setSuccess(false);
            result.setMessage(e.toString());
            logger.error(e.toString());
        }
        return result;
    }
}
